      SUBROUTINE RAST2(ANG2,ANG2D,ANG2DD)
C
      IMPLICIT REAL*8(A-H,O-Z)
C
      COMMON/CONSTS/PI,TWOPI,RADIAN
C
      COMMON/CRASTR/DELA(3),TAUA(4,3),ANG20(3),ADD0(3),TC(3),TTAB(4,3)
C
      COMMON/CSTVAL/TSTART,DUMM3(40)
C
      COMMON/ISECBD/I2BDY,NDOF2,IRAST,NDEP2,IARST(3),IRSCY(3)
C
      COMMON/RPOOL1/DUMM1(10),TIME,DUMM2(114)
C
C
      DIMENSION ANG2(3),ANG2D(3),ANG2DD(3)
C
C
      DT=TIME-TSTART
C
C     LOOP TO CALCULATE PRESCRIBED MOTION FOR EACH AXIS
C
      DO 100 I=1,3
      ANG2(I)=ANG20(I)
      ITEST=IARST(I)
      DA=0.0D0
      D1A=0.0D0
      D2A=0.0D0
C
      IF(ITEST.EQ.0) GO TO 90
C
      DT1=DT-TAUA(1,I)
      IF(DT1.LT.0.0D0) GO TO 90
C
      TCYC=TC(I)
      N=DT1/TCYC
C
      IF(N.LT.IRSCY(I)) GO TO 10
      IF(ITEST.EQ.1) GO TO 90
      DA=DELA(I)*IRSCY(I)
      GO TO 90
C
   10 CONTINUE
C
      T2=TAUA(2,I)
      T3=TAUA(3,I)
      T4=TAUA(4,I)
C
C     CALCULATE TIME RELATIVE TO START OF THIS CYCLE
C
      DTC=DT1-N*TCYC
C
C     SELECT TYPE OF CYCLE
C
      IF(ITEST.EQ.2) GO TO 50
C
C     TYPE 1 CYCLE
C
      TCL=TCYC/2.0D0
C
      DEL=DELA(I)
      ADD=ADD0(I)
      IF(DTC.LE.TCL) GO TO 20
C
C     IN SECOND HALF CYCLE
C
      DTC=DTC-TCL
      DA=DEL
      DEL=-DEL
      ADD=-ADD
C
   20 CONTINUE
C
      IF(DTC.LE.TTAB(1,I)) GO TO 90
      COEF=T3*ADD/PI
      IF(DTC.GT.TTAB(2,I)) GO TO 25
      T=DTC-TTAB(1,I)
      ARG=PI*T/T3
      SARG=DSIN(ARG)
      CARG=DCOS(ARG)
      D2A=ADD*SARG
      D1A=COEF*(1.0D0-CARG)
      DA=DA+COEF*(T-T3*SARG/PI)
      GO TO 90
C
   25 CONTINUE
C
      IF(DTC.GT.TTAB(3,I)) GO TO 30
      T=DTC-TTAB(2,I)
      D1A=2.0D0*COEF
      DA=DA+COEF*(T3+2.0D0*T)
      GO TO 90
C
   30 CONTINUE
C
      IF(DTC.GT.TTAB(4,I)) GO TO 40
      T=DTC-TTAB(3,I)
      ARG=PI*T/T3
      SARG=DSIN(ARG)
      CARG=DCOS(ARG)
      D2A=-ADD*SARG
      D1A=COEF*(1.0D0+CARG)
      DA=DA+COEF*(T3+2.0D0*T4+T+T3*SARG/PI)
      GO TO 90
C
   40 CONTINUE
C
      DA=DA+DEL
      GO TO 90
C
   50 CONTINUE
C
C     TYPE 2 CYCLE
C
      DEL=DELA(I)
      DA=N*DEL
      D1A=0.0D0
      D2A=0.0D0
      IF(DTC.LE.TTAB(1,I)) GO TO 60
      DA=DA+DEL
      GO TO 90
C
   60 CONTINUE
C
      T=DTC
      ARG=TWOPI*T/T2
      SARG=DSIN(ARG)
      CARG=DCOS(ARG)
      COEF=ADD0(I)*T2/TWOPI
C
      D2A=ADD0(I)*SARG
      D1A=COEF*(1.0D0-CARG)
      DA=DA+COEF*(T-T2*SARG/TWOPI)
C
   90 CONTINUE
C
      ANG2(I)=ANG2(I)+DA
      ANG2D(I)=D1A
      ANG2DD(I)=D2A
C
      ANG2(I)=ANG2(I)*RADIAN
      ANG2D(I)=ANG2D(I)*RADIAN
      ANG2DD(I)=ANG2DD(I)*RADIAN
C
  100 CONTINUE
C
C
      RETURN
C
      END
